<!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
<stack>
<name>in.2</name>
<id>-1</id>
<cardCount>5</cardCount>
<cardID>2292</cardID>
<listID>2381</listID>
<cantModify><false /></cantModify>
<cantDelete><false /></cantDelete>
<cantAbort><false /></cantAbort>
<cardSize>
<width>640</width>
<height>640</height>
</cardSize>
<script>-- HTML.edit v1.1.1 ©1994 by Murray M. Altheimon appleEvent theClass,theID,theSenderglobal errGlobalbink f4sbink aset lockErrorDialogs to TRUEget the itemDelimiterset the itemDelimiter to colonput last item of theSender into sendingProgramset the itemDelimiter to itif theClass is "aevt" and theID is "odoc" and sendingProgram is "Finder" thenset cursor to watchrequest appleEvent dataif it = "" then exit appleEventput it into fNameListgo last cd of bg "Editor"repeat with i = 1 to the number of lines of fNameListput FileType(line i of fNameList, "nodialog:errGlobal") into fTypeif errGlobal ≠ "" thenanswer "AppleEvent Error: “" & errGlobal & "”"put "" into errGlobalexit appleEventelse if fType = "TEXT" thensend "importHTML"&"e&(line i of fNameList)"e to bg btn id 21 of cd 1 of bg "Editor"end ifend repeatend ifend appleEventon importHTMLget (word 2 of the selectedLine of cd fld "index" of cd "index")if it ≥ number(cds in bg "editor") then go last cd of bg "Editor"else go cd (it+1)send "importHTML" to bg btn id 21 of cd 1 of bg "Editor"end importHTMLon startuphide scroll windowshowAbout 3set cursor to fingers0pass startupend startupon openStackhide scroll windowsend initialize to cd id 2292send setMenus to cd id 2292send setEntities to cd id 2292set cursor to fingers3pass openStackend openStackon closeStackif the hilite of cd btn id 9 of cd "prefs" then compactStackif there is a window "HTML.edit Help" then close window "HTML.edit Help"if there is a window "HTMLTools" then close window "HTMLTools"if there is a window "HTMLToolsColor" then close window "HTMLToolsColor"if there is a window "Entities" then close window "Entities"reset menubarpass closeStackend closeStack-- • handle paletteson suspendStackhidePalettesreset menubarpass suspendStackend suspendStackon resumeStackseekPalettessend setMenus to cd id 2292pass resumeStackend resumeStackon closePaletteglobal HeT_viz,HeC_vizif there is a window "HTMLToolsColor"then put the loc of window "HTMLToolsColor" into cd fld "toolsLoc" of cd "prefs"else if there is a window "HTMLTools"then put the loc of window "HTMLTools" into cd fld "toolsLoc" of cd "prefs"put FALSE into HeT_vizput FALSE into HeC_vizend closePaletteon showToolsif the short name of this bg ≠ "Editor" then exit showToolsget cd fld "toolsLoc" of cd "prefs"if it = "" or optionKey() = down then get item 1 of the loc of bg btn "ZoomBox" - 191&",68"else get itif there is a window "HTMLTools" then show window "HTMLTools"else if there is a window "HTMLToolsColor" then show window "HTMLToolsColor"else if (item 2 of line 1 of getMode() = 8) then palette "HTMLToolsColor",itelse palette "HTMLTools",itend showToolson hidePalettesglobal HeT_viz,HeC_vizput viz("HTMLTools") into HeT_vizif HeT_viz then hide window "HTMLTools"put viz("HTMLToolsColor") into HeC_vizif HeC_viz then hide window "HTMLToolsColor"end hidePaletteson seekPalettesglobal HeT_viz,HeC_vizif HeC_viz = TRUE then showTools colorelse if HeT_viz = TRUE then showToolsend seekPaletteson closePalettesif there is a window "HTML.edit Help" then close window "HTML.edit Help"if there is a window "HTMLTools" then close window "HTMLTools"if there is a window "HTMLToolsColor" then close window "HTMLToolsColor"end closePalettes-- • standardon commandKeyDown kIF k = "/" or k = "?" then HTMLHelpelse if k = 0 then selectFromIndexelse if k = 1 then go cd "Index"else if k = 2 then go prevelse if k = 3 then go nextelse if k = 4 then go cd "mH"else if k = 5 then go cd "mF"else if k = 6 then go cd "prefs"ELSE if (shiftKey() ≠ down) thenif k = "H" or k = "R" then exit commandKeyDownelse if k = "A" and "field" is in the selectedChunk then select text of the selectedFieldelse if k = "E" then set the visible of scroll window to not the visible of scroll windowelse if k = "M" then set the visible of msg to not the visible of msgelse if k = "O" then send "importHTML" to this cdelse pass commandKeyDownELSE pass commandKeyDownend commandKeyDownon returnInFieldglobal useHTMLReturnif useHTMLReturn = TRUE and optionKey() = down and shiftKey() = down thensetUndoif length(selectedText) > 0 then put "<BR>"&return after the selectionelse type "<BR>"&returnelse if useHTMLReturn = TRUE and optionKey() = down thensetUndoif length(selectedText) > 0 then put "<P>"&return after the selectionelse type "<P>"&returnelse pass returnInFieldend returnInFieldon doMenu iif i = "New Background" then beepelse if i = "Import Document…" thengo last cd of bg "Editor"send "importHTML" to this cdelse if i = "Export Document…" thenget number(this cd)if (the short id of this bg = 5539) then send "exportHTML" to this cdelse beepelse if i = "Compact Stack" thenclosePalettespass doMenuelse pass doMenuend doMenuon idleif there is a window "progress" then close window "progress"pass idleend idleon showAbout theTimehidePalettesif theTime = "" then put 999 into theTimeif (item 2 of line 1 of getMode() < 8) then showWind "AboutBoxBW",theTimeelse showWind "AboutBox",theTimeseekPalettesend showAbouton showWind wind,timeget the tickspicture wind,resource,shadowif there is no window wind then answer "OUT OF MEMORY ERROR:"&return&"Unable to display graphic. Allocate more memory to this application."else wait until the mouseClick or the ticks - it > (time * 60)visual zoom closeif there is a window wind then close window windend showWindon mouseDownInPicture windclose window windend mouseDownInPictureon stopUsingrepeat with i = 1 to number(lines in the stacksInUse)stop using stack (line i of the stacksInUse)end repeatend stopUsingon compactStack nowstopUsingget the short name of cd btn id 10 of cd "prefs"if it = "Always" then get ">0%"elsedelete first char of itdelete last char of itput it/100 into thresholdend ifif (the freeSize of this stack/the size of this stack > threshold) or now = TRUEthen doMenu "Compact Stack"end compactStackon printTextif the short name of this bg = "Editor" thenopen report printing with template "PrintDocument"print this cdclose printingend ifend printText-- • HTML Helpon HTMLHelp iglobal topicif i = "HTML" then get "A Beginner's Guide to HTML"else if the paramCount = 0 or i = "" then get "Contents"else get iput it into topicif i = "About Box" thenif viz("HTML.edit Help") then hide window "HTML.edit Help"hidePalettesshowAboutseekPalettesif there is a window "HTML.edit Help" thenshow window "HTML.edit Help"end ifelse if i = "Palette Help" then paletteHelpelse if i ≠ "false" thenif helpAvailable() and there is not a window "HTML.edit Help" thenget trunc(the width of cd window/6)&",44,"&trunc(5/6*the width of cd window)&","&(the height of cd window)-26Textoid "HTML.edit Help",topic,bigWindoidZoom,itbinkend ifif there is a window "HTML.edit Help" thenset the UnLockAllowed of window "HTML.edit Help" to FALSEset text of window "HTML.edit Help" to topic -- load from RSRCset fieldTransfer of window "HTML.edit Help" to "fld id 15" -- txfer to fldelseanswer "ERROR:"&return&"Unable to display Help window. Please place the file 'HTML.edit.Help' in the same folder as HTML.edit and try again." with "Cancel"exit to HyperCardend ifunlock screen with dissolve very fastend ifend HTMLHelpon clickInText theWord,WName,w,s1,s2,f,s2,theStyle -- click in Help windowif theStyle contains "group" and theStyle contains "underline" then HTMLHelp theWordend clickInTextfunction helpAvailableif optionKey() = down or "HTML.edit Help" is in the windows then return TRUE -- • deleteif stackName(cd fld "helpStack" of cd "prefs") is in the stacksInUse then return TRUEelserepeat 1 timesget fileExists(cd fld "helpStack" of cd "prefs","nodialog:errGlobal")if errGlobal = ""then start using stack cd fld "helpStack" of cd "prefs"else start using stack "HTML.edit.Help"if "HTML.edit.Help" is not in the stacksInUsethen put "HTML.edit.Help" into cd fld "helpStack" of cd "prefs"elseput thePath(the long name of stack "HTML.edit.Help")&"HTML.edit.Help" into ¬cd fld "helpStack" of cd "prefs"return TRUEend ifend repeatend ifreturn FALSEend helpAvailableon setIndexed modeglobal indexedset the hilite of cd btn "indexed" of cd "prefs" to modeput mode into indexedend setIndexedon selectFromIndexglobal indexed,indexList,cardIDListif the short id of this bg = 5539 then get (number(this cd)-1) else get 1if indexed ≠ TRUE then indexStackshowDialog 7,4744,"Choose a document:",Chicago,12,indexList,it,"one",gY(132),gX(111)get the resultif line 1 of the result = 2 then exit selectFromIndexelse if line 1 of the result = 5 then go cd "index"else if line 1 of the result = 6 then go cd "prefs"else go cd id (line (line 2 of it) of cardIDList)end selectFromIndexon indexStacksend "indexStack" to bg btn id 21 of cd 1 of bg "Editor"end indexStack-- • HTML Codingon HTMLAddressif emptySelection() then exit HTMLAddress else setUndoput the selection into theTextput the number of lines of theText into nrepeat with i = 1 to nput "<P>" after line i of theTextend repeatif last char of theText ≠ return then put return after theTextput "<ADDRESS>"&return&theText&"</ADDRESS>" into the selectionend HTMLAddresson HTMLDate dateFormatget "{"&dateFormat&"}"if "field" is in the selectedChunk thenif the selection = "" then type itelse put it into the selectionelse answer "You must select some text or place the insertion point into an editor field for this function to work." with "Cancel"end HTMLDateon HTML i -- modify text selection with HTML codesglobal hNumsetUndoput the hilite of cd btn id 37 of cd "prefs" into staySelectedput the selectedChunk into sChunkIF "field" is in sChunk thenget ""if i = "Horizontal Rule" then get ",<HR>,0"else if char 1 of i = "H" then -- Headingset the name of bg btn id 73 of cd 1 of bg "Editor" to "H"&hNumget "<H"&hNum&">,</H"&hNum&">,4"select sChunkelse if i = "Bold" then get "<B>,</B>,3"else if i = "Blockquote" then get "<BLOCKQUOTE>,</BLOCKQUOTE>,12"else if i = "Citation" then get "<CITE>,</CITE>,6"else if i = "Comment" then get "<!-- , >,5"else if i = "Definition" then get "<DFN>,</DFN>,5"else if i = "Emphasis" then get "<EM>,</EM>,4"else if i = "Italic" then get "<I>,</I>,3"else if i = "Keyboard" then get "<KBD>,</KBD>,5"else if i = "ISINDEX" then get ",<ISINDEX>,0"else if i = "Listing" then get "<LISTING>,</LISTING>,9"else if i = "Code" then get "<CODE>,</CODE>,6"else if i = "Sample" then get "<SAMP>,</SAMP>,6"else if i = "Strong Emphasis" then get "<STRONG>,</STRONG>,8"else if i = "StrikeThru" then get "<S>,</S>,3"else if i = "Subscript" then get "<SUB>,</SUB>,5"else if i = "Superscript" then get "<SUP>,</SUP>,5"else if i = "Typewriter" then get "<TT>,</TT>,4"else if i = "Preformatted" then get "<PRE>,</PRE>,5"else if i = "Title" then get "<TITLE>,</TITLE>,7"else if i = "Underline" then get "<U>,</U>,3"else if i = "Variable" then get "<VAR>,</VAR>,5"if it ≠ "" then -- found code, so modify text:put item 1 of it before the selectionput item 2 of it after the selectionif staySelected thenadd item 3 of it to word 2 of sChunkadd item 3 of it to word 4 of sChunkselect sChunkend ifend ifELSE answer "You must select some text or place the insertion point into an editor field for this function to work." with "Cancel"end HTMLon HTMLGlossaryif emptySelection() then exit HTMLGlossary else setUndoput the selection into theTextput the number of lines of theText into nif n mod 2 ≠ 0 thenanswer "HTML ERROR:"&return&"The text selection for an HTML Glossary must be an even number "&¬"of lines. The first line of each pair is the term, the second line is the definition."elserepeat with i = 1 to nif i mod 2 is 0 then next repeatput "<DT>" before line i of theTextend repeatrepeat with i = 1 to nif i mod 2 is 1 then next repeatput "<DD>" before line i of theTextend repeatif last char of theText ≠ return then put return after theTextput "<DL>"&return&theText&"</DL>"&return into the selectionend ifend HTMLGlossaryon HTMLImageglobal theURLput the selectedChunk into sChunkif "field" is in sChunk thenif the selection ≠ "" then get the selection else get theURLput "None,Top,Middle,Bottom" into theMenushowDialog 4,4745,"URL:","Alternative Text:",it,theMenu,1,gY(54),gX(221)if the result = "" then exit HTMLImageelse if line 2 of the result = "" thenanswer "You must enter a URL for this function to work."exit HTMLImageelse put the result into theResultsetUndoif char 1 of theResult ≠ 1 thenput space&"ALIGN="&item (char 1 of theResult) of "None,TOP,MIDDLE,BOTTOM" into theAlignelse put "" into theAlignif line 2 of theResult ≠ "" thenput space&"SRC=""e&rep(line 2 of theResult,":","/")"e into theSourceput rep(theSource,"http/","http:") into theSourceelse put "" into theSourceif line 3 of theResult ≠ "" thenput space&"ALT=""e&rep(line 3 of theResult,return)"e into theCommentelse put "" into theCommentget "<IMG"&theAlign&theSource&theComment&">"if the selection = "" then do "put it after"&&sChunkelse do "put it into"&&sChunkelse answer "You must select some text or place the insertion point into an editor field for this function to work." with "Cancel"end HTMLImageon HTMLLink i,iTextglobal theURLput "ERROR ON CREATING LINK:"&return into errput the selection into theTextput the selectedChunk into sChunkIF "bkgnd field 11" is in sChunk thenanswer err&"This function cannot use the URL field as a text selection."ELSE IF "field" is not in sChunk thenanswer err&"You must either select some text or place the insertion point in an editor field for this function to work." with "Cancel"ELSEif length(theText) > 90 then get rep(char 1 to 90 of theText,return,"¬")&"…" else get rep(theText,return,"¬")put "“"&it&"”" into sampleLinkif the paramCount ≠ 0 then -- URL from document nameif (i = 1 and number(this cd) = 2) or (i = 2 and number(this cd)-1 = number(cds in this bg)) thenbeepexit HTMLLinkelse if i = 1 then get fld id 4 of cd (number(this cd)-1) -- link to previouselse if i = 2 then get fld id 4 of cd (number(this cd)+1) -- link to nextelse -- link to specificglobal indexed,indexList,cardIDListif the short id of this bg = 5539 then get (number(this cd)-1) else get 1if indexed ≠ TRUE then indexStackshowDialog 7,4748,"Select the HREF document:",Chicago,12,indexList,it,"one",gY(132),gX(111)if line 1 of the result = 2 then exit HTMLLinkelse get (line (line 2 of the result) of indexList)end ifif (the hilite of cd btn id 63 of cd "prefs") then -- confirmshowDialog 2,4747,"Link to: "&&iText,sampleLink,it,gY(50),gX(241)get the resultend ifif it = "" then exit HTMLLinkelse put line 1 of it into theLinkelse -- get URL from dlogshowDialog 2,4743,"Enter the URL above.",sampleLink,theURL,gY(50),gX(241)get the resultif it = "" then exit HTMLLinkelse put line 1 of it into theLinkend ifsetUndodo "select"&&sChunkput "<A HREF=""e&theLink"e&">" before the selectionput "</A>" after the selectionif (the hilite of cd btn id 37 of cd "prefs") then -- staySelectedget length(theLink)+11add it to word 2 of sChunkadd it to word 4 of sChunkselect sChunkend ifEND IFend HTMLLinkon HTMLList tagsetUndoput the selection into theTextrepeat with i = 1 to number(lines of theText)put "<LI>" before line i of theTextend repeatif last char of theText ≠ return then put return after theTextput "<"&tag&">"&return&theText&"</"&tag&">" into the selectionend HTMLListon HTMLNamedAnchorif emptySelection() then exit HTMLNamedAnchor else setUndoput the selection into theTextask "Enter the name for this Named Anchor:"if it = "" then exit HTMLNamedAnchorelse put "<A NAME=""e&it"e&">"&theText&"</A>" into the selectionend HTMLNamedAnchoron convertParagraphif emptySelection() then exit convertParagraph else setUndoput the selection into theTextset cursor to watchlock screenrepeat while offset(return&return,theText) ≠ 0put rep(theText,return&return,return) into theTextend repeatput rep(theText,return,"<P>"&return&return) into theTextput theText into the selectionunlock screenend convertParagraphon replaceTextglobal src,replaceAll,globalRep,miniGREPif the selection ≠ "" then put the selection into srcget replaceAll&","&globalRep&","&miniGREPshowDialog 2,4746,"Search for:","Replace with:",src,it,gY(68),gX(222)get the resultif it = "" or line 2 of it = "" then exit replaceTextsetUndoput item 1 of line 1 of it into replaceAllput item 2 of line 1 of it into globalRepput item 3 of line 1 of it into miniGREPput line 2 of it into srcput line 3 of it into rplcif miniGREP thenput grepConvert(src) into srcput grepConvert(rplc) into rplcend ifput number(cds of bg "Editor") into endOpif globalRep and endOp > 1 then -- replace in all docsanswer "GLOBAL REPLACE:"&return&"Changes made to other documents will not be undoable."&&¬"Do you still wish to continue?" with "Yes" or "No"if it = "No" then exit replaceTextlock messagespush cdif endOp > 5then progressWindow "©Dome","Progress","Globally replacing text…"&return&¬"Type ⌘-. to halt processing.",4130repeat with c = 1 to endOpgo cd c of bg "Editor"repeat with i = 1 to 3get (src is in fld id i and not replaceAll)put rep(fld id i,src,rplc,replaceAll) into fld id iif it then exit repeatend repeatif viz("Progress") then set thePercent of window "Progress" to (i/endOp)*100 else bzif it then exit repeatend repeatpop cdif viz("Progress") then close window "Progress"binkelserepeat with i = 1 to 3get (src is in fld id i and not replaceAll)put rep(fld id i,src,rplc,replaceAll) into fld id iif it then exit repeatend repeatend ifbinkend replaceTextfunction grepConvert iget rep(i,"\l",numToChar(10))get rep(it,"\n",return&numToChar(10))get rep(it,"\r",return)get rep(it,"\s",space)get rep(it,"\t",tab)return itend grepConverton tableConvertif emptySelection() then exit tableConvert else setUndoset cursor to watchput the selection into theTextput cd fld id 27 of cd "prefs" into sourceCharsput cd fld id 28 of cd "prefs" into replaceCharsput number(lines in sourceChars) into endOprepeat with i = 1 to endOpget char 1 of line i of sourceCharsif it = return then next repeatelse if it ≠ "" thenput line i of replaceChars into rif last char of r = return then delete last char of rput rep(theText,it,r) into theTextend ifend repeatput theText into the selectionbinkend tableConverton setLF modesetUndoset cursor to watchlock screenput numToChar(10) into LFrepeat with i = 1 to 3if mode thenput rep(fld id i,return,return&LF) into fld id iif char 1 of fld id i ≠ LF thenput LF before fld id iend ifelse put rep(fld id i,LF) into fld id iend repeatunlock screenend setLFon unwrapif emptySelection() then exit unwrap else setUndoput the selection into theTextset cursor to watchlock screenput rep(theText,return&return,"¶") into theTextput rep(theText,return," ") into theTextput rep(theText,"¶",return) into theTextput theText into the selectionunlock screenbinkend unwrapon DeHTMLif optionKey() ≠ down then lock screenif emptySelection() then exit DeHTML else setUndoput the selection into theTextput "HTML,HEAD,TITLE,BODY,H1,H2,H3,H4,H5,H6,B,I,TT,U,S,SUP,SUB,CODE,CITE,DFN,EM,STRONG,"&¬"KBD,SAMP,VAR,EM,STRONG,CITE,TT,PRE,PLAINTEXT,ADDRESS,BLOCKQUOTE,UL,DIR,DL,LISTING,MENU,OL" into codeListput number(items in codeList) into endOpprogressWindow "©Dome","Progress","Removing HTML Codes…"&return&"Type ⌘-. to halt processing.",4130repeat with i = 1 to endOpbzget item i of codeListput rep(theText,"<"&it&">") into theTextput rep(theText,"</"&it&">") into theTextif viz("Progress") then set thePercent of window "Progress" to (i/endOp)*100 else bzend repeatput rep(theText,"<P>") into theTextput rep(theText,"<LI>") into theTextbzput rep(theText,"<HR>") into theTextput rep(theText,"<BR>") into theTextbzput rep(theText,"<DT>") into theTextput rep(theText,"<DD>") into theTextif viz("Progress") then close window "Progress"put theText into the selectionunlock screenend DeHTMLfunction deleteHTML endCode,fldID -- ex. ("<BODY>",123)-- given <X>, delete all occ in HBF of <X> & </X>, returns TRUE if changesget FALSEput endCode into startCodeput "/" after char 1 of endCoderepeat with k = 1 to length(fldID)put char k of fldID into iif startCode is in fld id i or endCode is in fld id i then get TRUEput rep(fld id i,startCode) into fld id iput rep(fld id i,endCode) into fld id iend repeatreturn itend deleteHTMLon procError msganswer "HTML SYNTAX ERROR:"&return&msg&return&return&"The text parser will not process this HTML code." with "Continue"exit to HyperCardend procError-- • functionson keyDownglobal undoneput FALSE into undonepass keyDownend keyDownon setUndo modeglobal header,body,footer,undoneif mode = "restore" thenif not undone then exit setUndoget fld id 1put header into fld id 1put it into headerget fld id 2put body into fld id 2put it into bodyget fld id 3put footer into fld id 3put it into footerget ""else if mode = "clear" thenput "" into headerput "" into bodyput "" into footerelse if mode = "report" thenanswer "UNDO CONTENTS:"&return&"Header: "&length(header)&" chars."&return&"Body: "&length(body)&" chars."&return&"Footer: "&length(footer)&" chars."else -- save fld contentsput fld id 1 into headerput fld id 2 into bodyput fld id 3 into footerend ifput (mode ≠ "clear") into undoneend setUndofunction trim irepeatif last char of i = return or last char of i = space then delete last char of ielse return iend repeatend trimfunction gX xOffreturn trunc(item 3 of the screenRect/2 - item 1 of the loc of cd window) - xOffend gXfunction gY yOffreturn trunc(item 4 of the screenRect/2 - item 2 of the loc of cd window) - yOffend gYfunction inEditorreturn (the short id of this bg = 5539)end inEditorfunction zoomOK -- returns TRUE if document window zoomed fully to cd windowreturn the height of cd window - item 4 of the rect of fld id 6 = 2¬and the width of cd window - item 3 of the rect of fld id 6 = 2end zoomOKfunction saveCurrentText -- give the user the opportunity to save the current textget length(fld id 1) + length(fld id 2) + length(fld id 3)if it ≤ 3 then return FALSEelseanswer "Do you want to export the "&it&" characters of the current text before it is cleared?"¬with "Cancel" or "Yes" or "No"if it is "Cancel" then return itelse return (it is "Yes")end ifend saveCurrentTextfunction emptySelectionif the selection = "" thenanswer "You must select some text for this function to work." with "Cancel"return TRUEelse return FALSEend emptySelectionfunction stackName pathget length(path)repeat with i = it down to 1if char i of path = ":" then return char (i+1) to it of pathend repeatreturn pathend stackNamefunction thePath pathrepeat with i = length(path) do